package word413.chapter13;



public class TestGeometricObject {
  /** Main method */
  public static void main(String[] args) {
    // Declare and initialize two geometric objects
    GeometricObject geoObject1 = new Circle(5);
    GeometricObject geoObject2 = new Rectangle(5, 3);
    GeometricObject geoObject3 = new Square(6);

    System.out.println("第1和第3图形一样吗 " +
      equalArea(geoObject1, geoObject2));

    System.out.println("第2和第3图形一样吗" +
            equalArea(geoObject2, geoObject3));
//
//
//    // 返回第1个图形的面积和周长
    displayGeometricObject(geoObject1);
    // 返回第2个图形的面积和周长
    displayGeometricObject(geoObject2);
    // 返回第3个图形的面积和周长
    displayGeometricObject(geoObject3);

    //查找函数运行
    ifmax_min(geoObject1,geoObject2,geoObject3);
  }

  /** A method for comparing the areas of two geometric objects */
  public static boolean equalArea(GeometricObject object1,
      GeometricObject object2) {
    return object1.getArea() == object2.getArea();
  }

  /** A method for displaying a geometric object */
  public static void displayGeometricObject(GeometricObject object) {
    System.out.println();
    System.out.println("这个图形的面积是" + object.getArea());
    System.out.println("这个图形的周长是" + object.getPerimeter());
  }

  public static void ifmax_min(GeometricObject object1,GeometricObject object2,GeometricObject object3) {
    double area1=object1.getArea();
    double area2=object2.getArea();
    double area3=object3.getArea();
    double prem1=object1.getPerimeter();
    double prem2=object2.getPerimeter();
    double prem3=object3.getPerimeter();
    System.out.println();
    System.out.println("第一个图形的面积是" + object1.getArea());
    System.out.println("第二个图形的面积是" + object2.getArea());
    System.out.println("第三个图形的面积是" + object3.getArea());
    double temp = area1>area2 ? area1 : area2;
    double temp1= temp > area3 ? temp : area3;
    System.out.println("最大的图形面积是" + temp1);

    System.out.println();
    System.out.println("第一个图形的周长是" + object1.getPerimeter());
    System.out.println("第二个图形的周长是" + object2.getPerimeter());
    System.out.println("第三个图形的周长是" + object3.getPerimeter());
    double temp2 = prem1>prem2 ? prem2 : prem1;
    double temp3= temp2 > prem3 ? prem3 : temp2;
    System.out.println("最小周长是" + temp3);

  }

}
